package com.qf.openapi.web.master.controller;

import com.qf.openapi.web.master.entity.ApiMapping;
import com.qf.openapi.web.master.service.ApiMappingService;
import com.qf.openapi.web.master.vo.ResultVo;
import com.qf.openapi.web.master.vo.TableVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/apiMapping")
@Slf4j
public class ApiMappingController {
    @Autowired
    ApiMappingService apiMappingService;

    @RequestMapping("/table")
    public TableVo<ApiMapping> table(Integer page, Integer limit, ApiMapping apiMapping) {
        TableVo<ApiMapping> tableVo = apiMappingService.getApiMappingsByContdition(page, limit, apiMapping);
        return tableVo;
    }

    @PostMapping("/delete")
    public ResultVo delete(Integer[] ids) {
        return apiMappingService.delApiMappingByIds(ids);
    }

    @PostMapping("/add")
    public ResultVo add(ApiMapping apiMapping) {
        return apiMappingService.addApiMapping(apiMapping);
    }

    @PostMapping("/update")
    public ResultVo updateUser(ApiMapping apiMapping) {
        return apiMappingService.updateApiMapping(apiMapping);
    }
}
